<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 策略模式：把一系列算法或者数据封装起来，可以避免分支语句
        var obj = {
            A (salary) {
                return salary * 4
            },
            B (salary) {
                return salary * 3
            },
            C (salary) {
                return salary * 2
            }
        }
        function calcMoney (salary, rank) {
            return obj[rank](salary)
        }
        console.log(calcMoney(10000, 'A'))
        console.log(calcMoney(3000, 'C'))

    </script>
</body>
</html>